{extend name="base" /}
{block name="body"}
<div class="layui-card">
    <div class="layui-card-header">
        <form class="layui-form toolbar">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <div class="layui-btn-group">
                        <a href="{:url('lnadmin/store/add')}" class="layui-btn ajax-iframe" data-width="600px" data-height="475px">新增</a>
                    </div>
                </div>
                <div class="layui-inline">
                    <input name="keyword" class="layui-input" placeholder="商户名称/联系电话" autocomplete="off"/>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn icon-btn" lay-filter="ListSearch" lay-submit>
                        <i class="layui-icon">&#xe615;</i>搜索
                    </button>
                </div>
            </div>
        </form>

    </div>
    
    <table id="tableList" lay-filter="tableList"></table>
    <!-- 表格操作列 -->
    <script type="text/html" id="tableTBTrack">
        <a href="{:url('lnadmin/store/edit')}?id={{d.id}}" class="layui-btn layui-btn-sm ajax-iframe" data-width="600px" data-height="475px">修改商户</a>
        <a href="{:url('lnadmin/store/del')}?id={{d.id}}" class="layui-btn layui-btn-danger layui-btn-sm ajax-delete">删除商户</a>
    </script>
    <!-- 权限列 -->
    <script type="text/html" id="status">
        <input type="checkbox" name="status" lay-skin="switch" lay-filter="*" lay-text="正常|锁定" data-url="{:url('lnadmin/store/edit')}?id={{d.id}}" {{d.status==1?'checked':''}}>
    </script>

</div>
{/block}

{block name="js"}
<script>
    layui.use(['layer', 'form', 'table', 'util', 'dropdown'], function () {
        var table = layui.table;
        // 渲染回访表格
        var insTb = table.render({
            elem: '#tableList',
            url: "{:url('lnadmin/store/index_json')}",
            page: true,
            cellMinWidth: 100,
            limit:'15',
            limits:[15,30,50,100,200,500],
            cols: [[
                {type:'numbers',title:'#'},
                {field: 'name', align: 'left', sort: true, title: '名称'},
                {field: 'contact', align: 'left', sort: true, title: '联系人'},
                {field: 'mobile', align: 'center', sort: true, title: '电话',width:120},
                {field: 'taocan_name', align: 'center', sort: true, title: '套餐'},
                {field: 'exp_time', align: 'center', sort: true, title: '过期时间'},
                {field: 'exp_day', align: 'center', sort: true, title: '剩余天数'},
                {field: 'create_time', align: 'center', sort: true, title: '创建时间'},
                {align: 'center', sort: true, title: '状态',templet:'#status',width:100},
                {align: 'center', toolbar: '#tableTBTrack', title: '操作', minWidth: 220}
            ]],
            parseData: function(res){ //res 即为原始返回的数据
                return {
                  "code": res.code, //解析接口状态
                  "msg": res.msg, //解析提示文本
                  "count": res.data.total, //解析数据长度
                  "data": res.data.data //解析数据列表
                };
            }
        });
        form.on('submit(ListSearch)', function (data) {
            insTb.reload({where: data.field, page: {curr: 1}});
            return false;
        });
    });

</script>
{/block}